/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mvp.levelup.threads;

import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author WORKSPOT2
 */
public class PartProcessor implements Runnable
{

    private AtomicInteger counter;
    private int delay;
    public PartProcessor(AtomicInteger counter, int delay)
    {
        this.counter = counter;
        this.delay = delay;
    }

    @Override
    public void run()
    {
        try
        {
            int i = 10;
            while (i >0)
            {
                try
                {
                    Thread.sleep(delay);
                }
                catch (InterruptedException ex)
                {
                    
                }
                i--;
            }
        }
        finally
        {
            counter.decrementAndGet();
        }
    }
}
